package MultiThread;

import java.util.Date;

/**
 * Created by asus on 2017/10/8.
 */
public class MyTaskTest extends java.util.TimerTask{

    public MyTaskTest() {
        System.out.println("初始化，i="+i);
    }

    int i=0;

    public void run() {

        i++;
        System.out.println(new Date()+"开始进入任务,i++"+i);
        try {
            System.out.println(new Date()+"-----"+i+"------线程准备睡眠两秒");
//                TimeUnit.SECONDS.sleep(2000);
            Thread.sleep(2000);
            System.out.println(new Date()+"------"+i+"-----线程准备睡眠完毕");
            i--;
            System.out.println(new Date()+"       i--        "+i);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
